package jvm;

public class FinalizeTest1 {
    public static long num;
    public static void main(String[] args) throws InterruptedException {
        FinalizeTest1[] arr = new FinalizeTest1[100000];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = new FinalizeTest1();
        }
        arr = null;
        System.gc();

        Thread.sleep(1000);
    }

    @Override
    protected void finalize() throws InterruptedException {
        Thread.sleep(1);
        System.out.println(num ++); // finalize方法不一定会执行完全
    }
}
